import lejos.pc.comm.NXTComm;
import lejos.pc.comm.NXTConnector;

public class con2Ini {
    
	public static void main (String [ ] args){
		
		Joystick nativa = new Joystick();
		SMJ joystick = new SMJ(nativa);
		SMR robot = new SMR(joystick, new CA(),conexion());
		nativa.start();
		
		try {
	        Thread.sleep(1000);
		} catch (Exception e) {
			System.out.println(e);
		}
		
		new Ventana(nativa.getFlag(), new ViewManager(robot.getAmbiente()));
		joystick.start();
	/* while(true)
	{
		System.out.println("Time: "+nativa.getTime());
		System.out.println("Value: "+nativa.getValue());
		System.out.println("Type: "+nativa.getType());
		System.out.println("Number: "+nativa.getNumber());
		
		try 
		{
                	Thread.sleep(2000);
            	} 
		catch (Exception e) 
		{
                	System.out.println(e);
            	}
	}*/
    }
	
	private static NXTConnector conexion(){
		NXTConnector con = new NXTConnector();	//NXTConnector permite el acceso remoto mediante Bluetooth
		if (!con.connectTo("NXT", NXTComm.LCP)) {	//LCP Lego Communications Protocol
	            System.err.println("Conexion robot fallida.!");
	          //  System.exit(0);
	    }
		return con;
	}
}
